/** 
 * FunctionNode.java
 * @author Lex
 * 2007-8-19 ����08:46:53
 */
package fun.parser.postfix;

import fun.parser.lexer.Token;

public class FunctionNode extends PostfixNode {
	private PostfixProgram[] arguments = null;

	public FunctionNode(Token funName) {
		super(PostfixNodeType.FUNCTION, funName);
		this.arguments = new PostfixProgram[0];
	}

	public FunctionNode(Token funName, PostfixProgram[] args) {
		this(funName);
		if (null != args)
			this.arguments = args;
	}

	public int getArgumentCount() {
		return this.arguments.length;
	}

	public PostfixProgram[] getArguments() {
		return this.arguments;
	}

	public String toString() {
		StringBuilder b = new StringBuilder();
		b.append(this.getToken().getImage()).append('[');
		for (int i = 0; i < this.arguments.length; i++) {
			b.append(this.arguments[i].toString());
			if (i < this.arguments.length - 1)
				b.append(", ");
		}
		b.append(']');
		return b.toString();
	}
}
